home *** CD-ROM | disk | FTP | other *** search
- Path: news.ncl.ac.uk!aidan!n5013784
- From: Tom Seddon <T.W.Seddon@ncl.ac.uk>
- Newsgroups: comp.lang.c
- Subject: What happens on realloc() failure?
- Date: Fri, 22 Mar 1996 19:37:44 +0000
- Organization: University of Newcastle upon Tyne
- Message-ID: <Pine.SOL.3.91-941213.960322192958.24127A-100000@aidan.ncl.ac.uk>
- NNTP-Posting-Host: aidan.ncl.ac.uk
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
-
- I am writing a program which will need to call realloc() a fair amount.
- What I would like to know is whether the original data is still usable if
- the realloc() fails. (Although it is unlikely that there will be problems
- with running out of memory, it is possible that there will be problems due
- to fragmentation of memory.)
-
- Since realloc() returns NULL on failure, is it safe to use the pointer to
- the malloc()ed area I was trying to resize? Or will the old area have
- been freed by free() and now be unusable? What does the ANSI standard
- have to say about this? I've never seen anything about this point before
- (although if it's in the FAQ I apologise, I must have missed it :-( )
-
- I'm using djgpp 1.12maint2 on a 486 so if anyone has some djgpp-specific
- information I'd be most grateful. My program is djgpp/386+/DOS specific so
- I'm not bothered at all about portability problems.
-
- Thanks in advance,
-
- --Tom
-
- | ** Tom Seddon ** E-mail: T.W.Seddon@ncl.ac.uk
- - . - www: http://www.ncl.ac.uk/~n5013784/
- /|\
- //|\\ If you help a friend in need, he's sure to remember you...
- ///|\\\ next time he's in need.
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-